var e = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")), a = require("../../@babel/runtime/helpers/asyncToGenerator"), t = require("../../mycomponent/payKeyboard/PayKeyboardAsync"), s = getApp();

Page({
    behaviors: [ t.payKeyboardAsync ],
    data: {
        popupSpecs: !1,
        need_password: !1,
        has_password: !1,
        site: ""
    },
    onLoad: function(e) {},
    getData: function() {
        var e = this;
        s._postNetWork({
            url: s.getNetAddresss("plugin.love-speed-pool.frontend.wallet-site.index"),
            success: function(a) {
                var t = a.data;
                1 == t.result ? e.setData({
                    site: t.data.site,
                    need_password: t.data.need_password,
                    has_password: t.data.has_password
                }) : s.tips(t.msg);
            }
        });
    },
    onSubmit: function() {
        var t = this;
        return a(e.default.mark(function a() {
            var n, o;
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    if (n = {
                        site: t.data.site
                    }, !t.data.need_password) {
                        e.next = 9;
                        break;
                    }
                    if (t.data.has_password) {
                        e.next = 5;
                        break;
                    }
                    return wx.navigateTo({
                        url: "/packageA/member/set_balance_password/set_balance_password"
                    }), e.abrupt("return");

                  case 5:
                    return e.next = 7, t.getPayKeyboardPassword();

                  case 7:
                    o = e.sent, n.password = o;

                  case 9:
                    s._postNetWork({
                        url: s.getNetAddresss("plugin.love-speed-pool.frontend.wallet-site.edit-info"),
                        data: n,
                        success: function(e) {
                            var a = e.data;
                            s.tips(a.msg), 1 == a.result && wx.navigateBack({
                                delta: 1
                            });
                        }
                    });

                  case 10:
                  case "end":
                    return e.stop();
                }
            }, a);
        }))();
    },
    payKeyboardComplete: function(e) {
        this.setData({
            popupSpecs: !1
        }), t.payKeyboardAsync.complete(e.detail);
    },
    getPayKeyboardPassword: function() {
        return this.setData({
            popupSpecs: !0
        }), new Promise(function(e, a) {
            t.payKeyboardAsync.addCompleteFn(function(a) {
                var t = s.getNetAddresss("payment.password.check");
                t += "&password=" + a, s._getNetWork({
                    url: t,
                    success: function(t) {
                        var s = t.data;
                        1 == s.result ? e(a) : wx.showModal({
                            title: "提示",
                            content: s.msg,
                            success: function(e) {
                                e.confirm && 2002 == s.data.code && wx.navigateTo({
                                    url: "/packageA/member/set_balance_password/set_balance_password"
                                });
                            }
                        });
                    },
                    fail: function(e) {
                        console.log(e);
                    }
                });
            });
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});